function t(t) {
    var e = {
        token: wx.getStorageSync("token"),
        id: t.data.id
    };
    o.default.request(e, function(t) {
        2 == t.status ? wx.requestPayment({
            timeStamp: t.info.paydata.timeStamp,
            nonceStr: t.info.paydata.nonceStr,
            package: t.info.paydata.package,
            signType: t.info.paydata.signType,
            paySign: t.info.paydata.paySign,
            success: function(t) {
                wx.showToast({
                    title: "兑换成功"
                }), setTimeout(function() {
                    wx.navigateTo({
                        url: "../order/order"
                    });
                }, 1500);
            },
            fail: function(t) {
                console.log(t);
            }
        }) : 3 == t.status ? wx.showModal({
            title: "提示",
            mask: !0,
            content: t.info,
            showCancel: !1
        }) : (wx.showToast({
            title: "兑换成功"
        }), setTimeout(function() {
            wx.navigateTo({
                url: "../order/order"
            });
        }, 800));
    }, function() {}, function() {}, "", !0, "entry/wxapp/exchange");
}

var e, o = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}(require("../../../utils/tools.js")), a = require("../../wxParse/wxParse.js"), n = getApp();

Page({
    data: {
        id: 0,
        indicatorDots: !1,
        vertical: !1,
        autoplay: !0,
        interval: 5e3,
        duration: 1e3,
        isScrollY: !0,
        current: 0,
        total: 0,
        isShowDialog: !1,
        isShowALLFriend: !1,
        goods: {},
        stepDetail: {},
        item: {},
        userLimitVO: {},
        oemType: "",
        oemId: "",
        productId: "",
        orderId: "",
        isEnoughCoin: !1,
        myCoin: 0,
        isShowInfo: !1,
        needToGetUserInfo: !1,
        authorizedUserInfo: {
            type: Boolean
        },
        isIphoneX: !1,
        isIphone: !1,
        from: "",
        isShowEmpty: !1,
        bgimage: "",
        is_qrcode: !1,
        author_show: 2,
        extra_info_tab: 1
    },
    onLoad: function(t) {
        e = this, t.id && (this.data.id = t.id);
    },
    switchTab: function(t) {
        this.setData({
            extra_info_tab: t.target.dataset.extra
        });
    },
    onReady: function() {
        wx.getSystemInfo({
            success: function(t) {
                if ("ios" == t.platform) {
                    e.setData({
                        isIphone: !0
                    });
                    t.model.indexOf("iPhone X") > -1 && e.setData({
                        isIphoneX: !0
                    });
                }
            }
        });
    },
    onShow: function() {
        var t = {
            action: "details",
            contr: "goods",
            token: wx.getStorageSync("token"),
            id: e.data.id
        };
        o.default.request(t, function(t) {
            wx.setNavigationBarTitle({
                title: t.info.goods.goods_name
            }), e.setData(t.info);
            var o = t.info.goods.introduce;
            a.wxParse("article", "html", o, e, 5);
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    swiperchange: function(t) {
        this.setData({
            current: t.detail.current
        });
    },
    exchange: function() {
        this.data.address ? wx.showModal({
            title: "提示",
            content: "确定要兑换该商品",
            success: function(o) {
                o.confirm ? t(e) : o.cancel && console.log("用户点击取消");
            }
        }) : wx.navigateTo({
            url: "../address/address"
        });
    },
    gotoCreateShareImg: function() {
        wx.navigateTo({
            url: "../goodscreateimg/goodscreateimg?id=" + e.data.id
        });
    },
    onReachBottom: function() {},
    setAddress: function() {
        wx.navigateTo({
            url: "../address/address"
        });
    },
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_farm/pages/index/index?parent_id=" + this.data.share.member_id
        };
    },
    closedialog: function() {
        this.setData({
            author_show: 2
        });
    },
    triggerALLFriend: function() {
        var t = !this.data.isShowALLFriend;
        if (t) e = n.img_url + "/step2gift/packupFriend.png"; else var e = n.img_url + "/step2gift/openFriend.png";
        this.setData({
            isShowALLFriend: t,
            bgimage: e
        });
    },
    getUserInfo: function(t) {
        if ("getUserInfo:ok" == t.detail.errMsg) {
            var a = {
                action: "register",
                contr: "home",
                token: wx.getStorageSync("token"),
                encryptedData: t.detail.encryptedData,
                iv: t.detail.iv
            };
            o.default.request(a, function(t) {
                e.exchange(), e.onShow();
            });
        }
    }
});